package com.ruoyi.project.platform.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.platform.domain.StyParameter;
import com.ruoyi.project.platform.service.IStyParameterService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 参数描述Controller
 * 
 * @author ruoyi
 * @date 2020-07-23
 */
@RestController
@RequestMapping("/platform/parameter")
public class StyParameterController extends BaseController
{
    @Autowired
    private IStyParameterService styParameterService;

    /**
     * 查询参数描述列表
     */
    @PreAuthorize("@ss.hasPermi('platform:parameter:list')")
    @GetMapping("/list")
    public TableDataInfo list(StyParameter styParameter)
    {
        startPage();
        List<StyParameter> list = styParameterService.selectStyParameterList(styParameter);
        return getDataTable(list);
    }

    /**
     * 导出参数描述列表
     */
    @PreAuthorize("@ss.hasPermi('platform:parameter:export')")
    @Log(title = "参数描述", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(StyParameter styParameter)
    {
        List<StyParameter> list = styParameterService.selectStyParameterList(styParameter);
        ExcelUtil<StyParameter> util = new ExcelUtil<StyParameter>(StyParameter.class);
        return util.exportExcel(list, "parameter");
    }

    /**
     * 获取参数描述详细信息
     */
    @PreAuthorize("@ss.hasPermi('platform:parameter:query')")
    @GetMapping(value = "/{parameterId}")
    public AjaxResult getInfo(@PathVariable("parameterId") Long parameterId)
    {
        return AjaxResult.success(styParameterService.selectStyParameterById(parameterId));
    }

    /**
     * 新增参数描述
     */
    @PreAuthorize("@ss.hasPermi('platform:parameter:add')")
    @Log(title = "参数描述", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody StyParameter styParameter)
    {
        return toAjax(styParameterService.insertStyParameter(styParameter));
    }

    /**
     * 修改参数描述
     */
    @PreAuthorize("@ss.hasPermi('platform:parameter:edit')")
    @Log(title = "参数描述", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody StyParameter styParameter)
    {
        return toAjax(styParameterService.updateStyParameter(styParameter));
    }

    /**
     * 删除参数描述
     */
    @PreAuthorize("@ss.hasPermi('platform:parameter:remove')")
    @Log(title = "参数描述", businessType = BusinessType.DELETE)
	@DeleteMapping("/{parameterIds}")
    public AjaxResult remove(@PathVariable Long[] parameterIds)
    {
        return toAjax(styParameterService.deleteStyParameterByIds(parameterIds));
    }
}
